123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- <template>
- <ShopPageHead></ShopPageHead>
- <main class="index_main" id="all_vue">
- <div class="shop_banner">
- <a class="shop_banner_a" href="" title="">
- <img class="shop_banner_img" src="@/public/img/6.png" title="" alt="">
- </a>
- </div>
- <!--子菜单和地区选择-->
- <ShopSubMenu2></ShopSubMenu2>
- <!-- 地区选择 -->
- <div class="categ_crumb_box clearfix_2">
- <!-- 当前位置 -->
- <div class="categ_crumb_left">
- <a class="categ_crumb_left_a" title=""> 当前位置: </a>
- <NuxtLink
- :to="`/xiangcunshangcheng/index.html`"
- class="categ_crumb_left_a"
- >
- 乡村商城
- </NuxtLink>
- >
- <span class="categ_crumb_left_text">{{name}}</span>
- </div>
- <!-- 当前位置 -->
- <!-- 当前商品所在地 -->
- <div class="categ_crumb_right clearfix" v-if="cityList.length > 0">
- <div class="categ_crumb_right_text">当前商品所在地:</div>
- <div class="categ_crumb_right_text hand">{{cityName}}</div>
- <div class="categ_crumb_right_btn back100 hand" @click="btn_if_categ_crumb_panel_fun" tabindex="1"
- @blur="categ_crumb_panel_btn_blur_fun">
- </div>
- </div>
- <!-- 当前商品所在地 -->
- <div class="categ_crumb_panel" v-show="if_categ_crumb_panel" tabindex="0"
- @click="categ_crumb_panel_focus_fun" @blur="categ_crumb_panel_blur_fun">
- <h4 class="categ_crumb_panel_h4">您可以选择以下详细地区</h4>
- <div class="categ_crumb_panel_btn_box clearfix">
- <span
- class="categ_crumb_panel_btn hand"
- :class="{ categ_crumb_panel_btn_only: item.id == chooseCityId }"
- v-for="item in cityList"
- @click="chooseCity(item.id)"
- >
- {{ item.name }}
- </span>
- </div>
- </div>
- </div>
- <!-- 您可以选择以下详细地区 -->
- <div class="categ_grey_box clearfix" v-if="secondNav.length > 0">
- <div class="categ_grey_head">您可以选择以下详细分类:</div>
- <div class="categ_grey_ul clearfix">
- <span
- :class="['categ_grey_btn hand', { 'categ_grey_btn_only': selectedSecondId == item.category_id }]"
- v-for="item in secondNav"
- @click="selectSecond(item)"
- >
- {{ item.alias }}
- </span>
- </div>
- </div>
- <!-- 您可以选择以下详细地区 -->
- <!-- 供应信息列表 -->
- <!-- <div class=" clearfix" v-show="choice_categ_num == 1"> -->
- <div class=" clearfix">
- <div class="categ_1_index clearfix">
- <div class="categ_head_box clearfix_2">
- <span class="categ_head_a">供应信息列表</span>
- <nuxt-link
- to="/xiangcunshangcheng/nongfuchanpin/gongying/list-1.html"
- class="categ_head_a_more"
- >
- 查看更多 >
- </nuxt-link>
- </div>
- <div class="categ_table clearfix">
- <div class="categ_table_head_box">
- <div class="categ_table_td_1">产品图片</div>
- <div class="categ_table_td_2">供求信息/公司</div>
- <div class="categ_table_td_3">发布时间</div>
- <div class="categ_table_td_4">地区</div>
- </div>
- <ShopNoData v-if="pageDataType1.length == 0" :pagetype="'class'"></ShopNoData>
- <div class="categ_table_li" v-for="item in pageDataType1" :key="item.id">
- <NuxtLink
- :to="getShopPathDetail1(item)"
- class="categ_table_li_a"
- :title="item.name"
- >
- <div class="categ_table_td_1">
- <img class="categ_table_td_1_img" :src="item.imgurl" alt="item.name">
- </div>
- <div class="search_table_td_2 ">
- <div class="search_table_td_2_in clearfix">
- <div class="search_table_td_2_head dot1">
- {{ item.name }}
- </div>
- <div class="search_table_td_2_dot2 dot2">
- {{ item.description }}
- </div>
- </div>
- </div>
- <div class="categ_table_td_3">{{getTime(item.created_at, 'year', 1)}}</div>
- <div class="categ_table_td_4 dot1">{{item.city_name}}</div>
- </NuxtLink>
- </div>
- </div>
- </div>
- </div>
- <div class=" clearfix">
- <div class="categ_1_index clearfix">
- <div class="categ_head_box clearfix_2">
- <span class="categ_head_a">求购信息列表</span>
- <nuxt-link
- to="/xiangcunshangcheng/nongfuchanpin/qiugou/list-1.html"
- class="categ_head_a_more"
- >
- 查看更多 >
- </nuxt-link>
- </div>
- <div class="categ_table clearfix">
- <div class="categ_table_head_box">
- <div class="categ_table_td_1">产品图片</div>
- <div class="categ_table_td_2">供求信息/公司</div>
- <div class="categ_table_td_3">发布时间</div>
- <div class="categ_table_td_4">地区</div>
- </div>
- <ShopNoData v-if="pageDataType2.length == 0" :pagetype="'class'"></ShopNoData>
- <div class="categ_table_li" v-for="item in pageDataType2" :key="item.id">
- <NuxtLink
- :to="getShopPathDetail1(item)"
- class="categ_table_li_a"
- :title="item.name"
- >
- <div class="categ_table_td_1">
- <img class="categ_table_td_1_img" :src="item.imgurl" alt="item.name">
- </div>
- <div class="search_table_td_2 ">
- <div class="search_table_td_2_in clearfix">
- <div class="search_table_td_2_head dot1">
- {{ item.name }}
- </div>
- <div class="search_table_td_2_dot2 dot2">
- {{ item.description }}
- </div>
- </div>
- </div>
- <div class="categ_table_td_3">{{getTime(item.created_at, 'year', 1)}}</div>
- <div class="categ_table_td_4 dot1">{{item.city_name}}</div>
- </NuxtLink>
- </div>
- </div>
- </div>
- </div>
- <ShopHotNews></ShopHotNews>
- </main>
- <!-- 页面底部 -->
- <HomeFoot></HomeFoot>
- </template>
- <script setup>
- //1.页面必备方法 start ---------------------------------------->
- import { ref, onMounted,watch } from 'vue'
- import { ElMessage } from 'element-plus'
- //1.页面必备方法 end ---------------------------------------->
- //2.页面路径 start ---------------------------------------->
- //2.1 获得页面数据id
- const route = useRoute();
- const router = useRouter()
- let articleId = 0; //把路径转换为数据id
- const targetSegment = getRoutePath(2);//返回第二层的路径id
- //通过导航路径反向查询导航id
- const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
- method: 'GET',
- query: {
- 'pinyin': targetSegment,
- },
- });
- if(getRouteId.code == 200){
- articleId = getRouteId.data.category_id
- }else{
- console.log("错误位置:获得页面路径")
- }
- //2.2 生成面包屑导航
- const name = ref('') //当前频道名称
- let getPageName = async () => {
- const pageName = await requestDataPromise('/web/getOneWebsiteCategory', {
- method: 'GET',
- query: {
- 'catid': articleId
- },
- });
- if (pageName.code == 200) {
- name.value = pageName.data.alias
- } else {
- console.log("错误位置:获取当前频道名称", pageName.message)
- }
- }
- getPageName();
- //2.3 获得子栏目列表
- const secondNav = ref([]);
- const selectedSecondId = ref(route.query.catid);//当前选中了哪个子导航
- let getSecondNav = async () => {
- const listData = await requestDataPromise('/web/getWebsiteModelCategory', {
- method: 'GET',
- query: {
- 'placeid': 1,
- 'pid': articleId,
- 'num': 50,
- },
- });
- if (listData.code == 200) {
- secondNav.value = listData.data
- } else {
- console.log("错误位置:获得子级栏目列表")
- }
- }
- getSecondNav();
- //2.4 获得cityid
- const cityId = ref(route.query.cityid)
- //2.页面路径 end ---------------------------------------->
- //3.选择商品所在地 start ---------------------------------------->
- //您可以选择以下详细分类:
- const choice_categ_num = ref(1)
- // 您可以选择以下详细地区=btn
- const if_categ_crumb_panel_btn_num = ref(0)
- const if_categ_crumb_panel = ref(false)// 当前商品所在地下拉板
- const if_categ_crumb_panel_click = ref(false)// //判断是否点击在下拉板内
- const btn_if_categ_crumb_panel_fun = () => {//点击下拉btn
- if_categ_crumb_panel.value = !if_categ_crumb_panel.value
- }
- const categ_crumb_panel_btn_blur_fun = () => {//btn失去焦点事件
- setTimeout(() => {//的延迟器
- if (if_categ_crumb_panel_click.value == true) {//判断鼠标是否点击下拉panel
- //点击在下拉panel内
- } else {//没点击在下拉panel内
- if_categ_crumb_panel.value = false
- }
- }, 100);
- }
- //点击下拉panel
- const categ_crumb_panel_focus_fun = () => {
- if_categ_crumb_panel_click.value = true
- if_categ_crumb_panel.value = true
- }
- //下拉panel失去焦点事件
- const categ_crumb_panel_blur_fun = () => {
- if_categ_crumb_panel_click.value = false
- if_categ_crumb_panel.value = false
- }
- //获得详细地址列表
- const cityName = ref('')
- const cityList = ref([])
- const chooseCityId = ref('')
- let getCityList = async (id) => {
- const shengData = await requestDataPromise('/web/selectWebsiteArea', {
- method: 'GET',
- query: {
- 'pid': id,
- },
- });
- console.log(id)
- console.log(shengData)
- if(shengData.code==200){
- cityList.value = shengData.data;
- cityName.value = shengData.data[0].pid_name;
- }else{
- ElMessage.error(shengData.message)
- }
- }
- //初始化的时候先获取一下城市列表
- if(cityId.value != undefined){
- getCityList(cityId.value);
- }
- //选择城市
- const chooseCity = (id) => {
- chooseCityId.value = id;
- router.replace({
- query: {
- ...route.query,
- select: id
- }
- })
- }
- //3.选择商品所在地 end ---------------------------------------->
- //4.搜索 start ---------------------------------------->
- //4.1 选择一个子导航
- const selectSecond = (item) => {
- //高亮显示当前选中的子导航
- selectedSecondId.value = item.category_id
- router.replace({
- query: { ...route.query, catid: item.category_id }
- })
- }
- const pageDataType1 = ref([]);//供应数据
- const pageDataType2 = ref([]);//求购数据
- const pageSearch = async () => {
- let params = {
- catid:"",//栏目id
- city_id:"",//城市id
- keyword:"",//搜索关键词 - 该页不需要
- page:1,
- pageSize:3,
- //type_id:1//1:供应 2:求购
- }
- if(selectedSecondId.value == undefined){
- params.catid = articleId
- }else{
- params.catid = parseFloat(selectedSecondId.value)
- }
- let routeCiteId = route.query.select;
- if(routeCiteId != undefined && routeCiteId != ''){
- params.city_id = parseFloat(routeCiteId)
- }else{
- if(cityId.value == undefined || cityId.value == '' || cityId.value == 'NaN'){
- //删除变量params中的city_id参数
- delete params.city_id
- }else{
- params.city_id = parseFloat(cityId.value)
- }
- }
- const pageData = await requestDataPromise('/web/getWebsiteshopList', {
- method: 'GET',
- query: params,
- });
- if (pageData.code == 200) {
- pageDataType1.value = pageData.data.type1;
- pageDataType2.value = pageData.data.type2;
- } else {
- console.log("错误位置:获得该页面数据失败!")
- }
- //开始请求数据
- console.log(params)
- console.log(pageData)
- }
- //页面初始化的时候调用一下搜索
- pageSearch();
- //每次路由一变化就重新请求数据
- watch(() => route.query.cityid, (newVal, oldVal) => {
- if(newVal != undefined){
- cityId.value = parseFloat(newVal)
- getCityList(newVal)
- }else{
- cityList.value = []
- }
- pageSearch()
- })
- watch(() => route.query.catid, (newVal, oldVal) => {
- pageSearch()
- })
- watch(() => route.query.select, (newVal, oldVal) => {
- if(newVal != undefined){
- pageSearch()
- }else{
- chooseCityId.value = '';
- pageSearch()
- }
- })
- //4.搜索 end ---------------------------------------->
- //5.广告 start ---------------------------------------->
- //获得所有广告
- let adImg1 = ref({})
- onMounted(async () => {
- const { $webUrl, $CwebUrl } = useNuxtApp();
- //从客户端启动广告
- //广告1
- let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=xcw_shopcategory_0001`
- const responseAd1 = await fetch(url, {
- headers: {
- 'Content-Type': 'application/json',
- 'Userurl': $CwebUrl,
- 'Origin': $CwebUrl
- }
- });
- const resultAd1 = await responseAd1.json();
- adImg1.value = resultAd1.data[0];
- })
- //5.广告 end ---------------------------------------->
- </script>
- <style lang="less" scoped>
- @import '@/assets/css/shop/class.less';
- </style>
|